/*
	你好！如果你对改此地图感兴趣，请加QQ群：762195010
	从而获得最新版本的地图，我也会尽量为你解答疑惑
*/

#define COMPILE_MODE_1 compileFinal
#define COMPILE_MODE_2 preprocessFile
//player setVariable ["as_side", side player, true];

as_version = "2.22";

1 fadeMusic 0.75;

as_view_map_time = 0;
as_npc_damage = 0;
as_time_pre = 0;
//_____________________________________禁用保存______________________________
enableSaving [ false, false ];

//_____________________________________等待服务器解析参数______________________________
waitUntil{!isNil "as_param_inited"};

//_____________________________________编译函数______________________________
if(!isServer) then
{
	#include "functions\initFunctions.hpp"
	#include "Units\support.sqf"
	#include "Units\astox.sqf"//防化物品信息，且fn_isUnitTox是本地执行
	call fn_fnc;
};


//_____________________________________草距______________________________
setTerrainGrid (Param_Terrain);

//视距
setViewDistance Param_ViewDistance;

//_____________________________________禁用第三人称______________________________
if(Param_DisableTPP == 1) then
{
	[] execVM "Scripts\Third_View_Lock.sqf";
};

//_____________________________________禁用热成像______________________________
if(Param_DisableTI == 1) then
{
	[] execVM "Scripts\naughtyThermal.sqf";
};
////_____________________________________禁用大炮电脑______________________________
if(Param_DisableAC == 1) then
{
	[] execVM "Scripts\naughtyThermal2.sqf";
};

//_____________________________________VcomAI______________________________
//[] execVM "Vcom\VcomInit.sqf";

//-------------------------zlt_fieldrepair----------------------------------------
[] execVM "Scripts\zlt_fieldrepair.sqf"; //修理

//_____________________________ Flip Script _____________________________
//翻车
if (!isDedicated) then {
 waitUntil {!isNull player && {time > 0}};
player addAction [
	"推正车辆", 
	"Scripts\FlipAction.sqf", 
	[], 
	0, 
	false, 
	true, 
	"", 
	"_this == (vehicle _target) && {(count nearestObjects [_target, ['landVehicle'], 5]) > 0 && {(vectorUp cursorTarget) select 2 < 0}}"
];
Player AddEventHandler ["Respawn", {
	(_this select 0) addAction [
		"推正车辆", 
		"Scripts\FlipAction.sqf", 
		[], 
		0, 
		false, 
		true, 
		"", 
		"_this == (vehicle _target) && {(count nearestObjects [_target, ['landVehicle'], 5]) > 0 && {(vectorUp cursorTarget) select 2 < 0}}"
	];
}];
};

//-------------------------irstrobe----------------------------------------
if(side player == east) then
{
	[] execVM "Scripts\irstrobe.sqf"; //玩家闪光
};

//_____________________________ GF Killfeed _____________________________
addMissionEventHandler ["EntityKilled", 
{
	_this call fn_killEffect;
}];

if(Param_Killfeed > 1) then{
	call fn_headShot;
};

//_______________________随机 语音____________________________
//
if(Param_Killfeed > 1) then{
	player addEventHandler ["InventoryClosed", 
	{ 
		private _r = random 100;
		
		if(_r < 25) then
		{	
			private _nears = nearestObjects [player, ["Man"], 2];
			{
				if((!isNull _x) && (_x != player) && (!alive _x) && (side _x != playerSide) && ( player distance _x < 2)) exitWith
				{
					[player, [format["pick_0%1", (floor random 7) + 1], 20]] remoteExec ["say", 0];
				};
			}forEach _nears;
		
			
		};

	}];
};


//_______________________CRS拟真____________________________
[] execVM "CRS\init.sqf";


//---------------------------fps-------------------------------------------
[] execVM "Scripts\show_fps.sqf"; //地图显示FPS信息


//_____________________________ 头顶名字 _________________________________
if(Param_ShowName == 1
&& side player == east) then
{
	[] execVM "Scripts\drawIcon3D.sqf";//
};


//绘制单位名字
[] spawn fn_drawName;

//_____________________________ Anti _________________________________
[] execVM "Scripts\anti.sqf";//反外挂

//_____________________________ jump _________________________________
[] execVM "Scripts\jump.sqf";//

//_____________________________ 手动打击 _________________________________
[] execVM "Scripts\hand_hit.sqf";//

//----------------------------Statusbar---------------------------------
if(Param_StatusBar == 1) then
{
	[] execVM "addons\statusBar\statusbar.sqf"; //fps 显示
};


//--------------------------索降----------------------------------------------
[] execVM "addons\AUR\functions\fn_aur_1.sqf"; //楼顶索降
//[] execVM "addons\AUR\functions\fn_aur_2.sqf"; //直升机索降（容易刮到飞机，并且现在有了伞降）
[] execVM "addons\AUR\functions\fn_advancedSlingLoadingInit.sqf"; //空中吊车绳
[] execVM "addons\AUR\functions\fn_advancedTowing.sqf";//拖车绳

//_____________________________ 耳塞 _____________________________
call COMPILE_MODE_1 COMPILE_MODE_2 "cmEarplugs\config.sqf"; // Original Virus MOD



[]spawn{
	waitUntil {sleep 1; (!isNull (findDisplay 12))};
	
	//_____________________________ 地图NVG效果 _____________________________
	if(Param_MapEffect == 1)then{
		[]spawn fn_mapEffect;
	};
	
	waitUntil{Sleep 5;(Param_MapEffect == 0) || {!isNil "as_map_effect_inited"}};
	//_____________________________ 地图图标 _____________________________
	if(Param_ShowPlayer == 1) then{[] execVM "Scripts\icons.sqf"};
};



//_____________________________________FAR______________________________
if(side player != east) then
{
	FAR_Enable = false;
};
//设置FAR默认参数
#include "include\params_far.hpp"
[] spawn COMPILE_MODE_1 COMPILE_MODE_2  "FAR_revive2\FAR_revive_init.sqf";

//_______________________让AI寻声而来____________________________
if(side player == east) then
{
	[player, ["Fired",{_this spawn fn_hearingAids}]] remoteExec ["addEventHandler", 2];
	//player addEventHandler ["Fired",{_this spawn fn_hearingAids;}];
};

//_______________________AI交火系统____________________________
[] execVM "zooloo75_FFIS\init.sqf";

//_______________________AL_fire____________________________
//execVM "AL_fire\setup_fire_player.sqf";

//_____________________________________Push______________________________
Push_fn_k1 = {
	params ["_veh", "_dir", "_spd"];
	_vel = velocity _veh;
	_veh setVelocity [0+(sin _dir*_spd),0+(cos _dir*_spd),(_vel select 2)];
};
Push_k1_Check2 = {
	_return = false;
	private _target = cursorTarget;
	if (!isNull _target && {_target isKindOf "LandVehicle" || {_target isKindOf "Ship"} || {_target isKindOf "StaticWeapon"} || {_target isKindOf "air"}} && {(_target distance player) < 8} && {stance player == "STAND"} && {vehicle player == player}) then { _return = true };
	_return
};

//--------------------------弹夹整理2----------------------------------------------
//[] execVM "Scripts\SAKY_MAGAZINE_REPACK.sqf";

//--------------------------无线电----------------------------------------------
/*
if(Param_Version >= 183) then{
	//1.82版本才支持这个脚本
	[]spawn compileFinal(preprocessFile"AFAR\init.sqf");
};
*/

if(Param_Blood == 1)then
{
	//[] execVM "GF_Blood_Stains_LITE\Credits.sqf";
	
	//________________	1.	GF_Bleeding Scipt	________________
	//[] execVM "GF_Blood_Stains_LITE\GF_Bleeding_LITE\GF_Set_Bleeding.sqf";	
		
		
	//________________	2.	GF_Blood_Pool Scipt	________________
	//[] execVM "GF_Blood_Stains_LITE\GF_Blood_Pool_LITE\GF_Set_Blood_Pool.sqf";


	//________________	3.	GF_Blood_Pool_BIS_Blood Scipt	________________	
	//[] execVM "GF_Blood_Stains_LITE\GF_Blood_Pool_BIS_Blood\GF_Set_Blood_Pool_BIS_Blood.sqf";	


	//________________	4.	GF_Blood_Shot Scipt	________________
	[] execVM "GF_Blood_Stains_LITE\GF_Blood_Shot_LITE\GF_Set_Blood_Shot.sqf";


	//________________	5.	GF_Particles Scipts	________________
	//[] execVM "GF_Blood_Stains_LITE\GF_Particles\GF_Blood_Particle_Killed\GF_Set_Blood_Particle_Killed.sqf";
	[] execVM "GF_Blood_Stains_LITE\GF_Particles\GF_Blood_Particle_Bleeding\GF_Set_Blood_Particle_Bleeding.sqf";


	//________________	6.	GF_SFX Scipts	________________
	//[] execVM "GF_Blood_Stains_LITE\GF_SFX\GF_SFX_Bullet_Impact\GF_SFX_Bullet_Impact.sqf";
	//[] execVM "GF_Blood_Stains_LITE\GF_SFX\GF_SFX_Killed_LITE\GF_SFX_Killed.sqf";
	//[] execVM "GF_Blood_Stains_LITE\GF_SFX\GF_SFX_Screaming\GF_Set_SFX_Screaming.sqf";
	
	systemchat "血腥效果[GF]初始化完成";
};

//////////////////////////////////////////////////////////////////////////////////////////////////

//---------------------------开车加速------------------------------
//execvm "Scripts\Turbo.sqf";

//---------------------------地图NVG------------------------------
//#include "vip_cmn\fn\vip_cmn_fnc.hpp"
//#include "vip_lit\fn\vip_lit_fnc.hpp"
//[true,[],[0,true,false],[[],true,false]] execVM "vip_lit\vip_lit_init.sqf";

//---------------------------一些按键响应------------------------------
[] spawn fn_onKeyDoUser;

//---------------------------下载数据------------------------------
[] execVM "DownloadData\init.sqf";

//清理
[] spawn fn_cleanup;


//--------------------------intro 介绍----------------------------------------------
[] spawn
{
	waitUntil {!isNil "as_server_done"};
	[] execVM "intro.sqf";
	
	playMusic "AmbientTrack01a_F";
};

//_____________________________________房主添加导弹覆盖（吓人的）______________________________

if(isServer) then
{
	[player, "SupportD41Fake"] call BIS_fnc_addCommMenuItem;  
};

//
[]spawn{
	if(player getUnitTrait "medic")exitWith{};
	waitUntil{sleep 60;player getVariable ["FAR_count_revive",0] >= 12};
	TitleText ["通过反复的救治过程，你已经学会医疗兵技能！", "Plain Down"];
	player setUnitTrait ["medic", true];
};

//红军死亡掉落一半金钱（但不会超过100）
if(side player == east) then
{
	player addEventHandler["killed",{
		private _unit = (_this select 0);
		private _money = _unit getVariable["as_money", 0];
		private _moneyLost = _money * 0.5;
		
		if(_moneyLost > 0)then{
			if(_moneyLost > 100)then{_moneyLost = 100;};
			[_unit, _moneyLost] remoteExec ["fn_putMoney", 2];
			_unit setVariable["as_money",  _money - _moneyLost, true];
		};
	}];
};

//游泳加速
[] spawn{
	while{true}do{
		waitUntil{Sleep 5;((position player) select 2) < -1.3};
		player setAnimSpeedCoef 1.5;
		waitUntil{Sleep 1;((position player) select 2) > -1.2};
		player setAnimSpeedCoef 1.0;
	};
};


//注意脚本要加在这里之前
//_____________________________ Abort Warning _____________________________
if(!isServer) then
{
	disableSerialization;
	while {true} do
	{
	waitUntil {!(isNull (findDisplay 49))};
	((findDisplay 49) displayCtrl 104) ctrlEnable false;
	any=[
		[
			["中止计时开始！","<t align = 'center' size = '2'>%1</t><br/>"],
			["15 秒...","<t align = 'center' size = '2'>%1</t><br/>"],
			["15 秒后可以中断连接，防止故意刷复活","<t align = 'center' color='#ffff00' size = '0.7'>%1</t>"]

		]
	] spawn BIS_fnc_typeText;

	_time = time;

	waitUntil {(isNull (findDisplay 49)) || time >= _time + 15};

	if (!(isNull (findDisplay 49))) then
	{
		((findDisplay 49) displayCtrl 104) ctrlEnable true;
		any=[
		[
			["你现在可以中止了，抱歉耽误了你宝贵的时间。","<t align = 'center' size = '2'>%1</t><br/>"]
		]
	] spawn BIS_fnc_typeText;
		waitUntil {isNull (findDisplay 49)};
	};
	};
};